package com.qixiaobao.common.core.rabbitmq.server;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName MsgSendServer
 * @Author yangxm
 * @Description mq消息发送
 * @Date 2022/12/6 10:41 PM
 */
@Component
public class MsgSendServer {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * @Description 发送消息
     * @Author yangxm
     * @Date 2022/12/6 11:02 PM
     * @Param [exchange：交换机, key：路由键, msg：消息, correlationData： 唯一，用于生产者确认消息]
     */
    public void sendDirectByRoute(String exchange, String key, String msg, CorrelationData correlationData){
        rabbitTemplate.convertAndSend(exchange, key, msg, correlationData);
    }
}
